package wge

import (
	"net/http"
	"time"
	"log"
	"os"
)

// 日志处理

var logger = log.New(os.Stdout, "[WGE] ", log.LstdFlags)

func Logger(c *Context) Stringer {
	start := time.Now()
	logger.Printf("Start %s %s from %s %s\n", c.Req.Method, c.Req.URL.Path, c.Req.RemoteAddr, c.Data.Encode())
	
	c.Next()
	
	logger.Printf("Complete %v %s in %v\n", c.status, http.StatusText(c.status), time.Since(start))
	
	return nil
}
